import router from './router'
const whiteList = ['/login'] // no redirect whitelist
// 路由守卫
router.beforeEach(async (to, from, next) => {
    const mobileToken = window.sessionStorage.getItem('xuanpin')
    if (mobileToken) {
        // 如果已经登录
        if (to.path === '/login') {
            next('/')
        } else if (!mobileToken) {
            next('/login')
        } else {
            next()
        }
    } else if (whiteList.indexOf(to.path) !== -1) {
        // 如果前往的路径是白名单内的,就可以直接前往
        next()
    } else {
        // console.log(6)
        next('/login')
    }
})
